package top.lishuoboy.docker1.controller;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DockerController {
    @Autowired
    StringRedisTemplate redisTemplate;

    @GetMapping("hello")
    public Object hello() {
        return ListUtil.list(false, "你好", "Docker");
    }

    @GetMapping("helloRedis")
    public Object helloRedis() {
        redisTemplate.opsForValue().set("lishuoboy-docker1", DateUtil.now());
        String redisVal = redisTemplate.opsForValue().get("lishuoboy-docker1");
        return ListUtil.list(false, "helloRedis", redisVal);
    }


    @Value("${my.env-test.name:张三111}")
    String name;

    @GetMapping("helloEnv")
    public Object helloEnv() {
        return ListUtil.list(false, "你好", name);
    }
}
